// components/authToast/authTip.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showModel: {
      type: Boolean,
      value: false
    },//
  },

  /**
   * 组件的初始数据
   */
  data: {
    showModel:false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //获取用户信息新接口
    agreeGetUser: function (e) {
      let that = this
      that.setData({
        showModel: false
      })
      //设置用户信息本地存储
      try {
        // 可以将 res 发送给后台解码出 unionId
        if (e.detail.errMsg == "getUserInfo:ok") {
          let res = e.detail;
          res.userInfo.nickName = res.userInfo.nickName.replace(/\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g, "");
          app.globalData.userInfo = res.userInfo;
          app.globalData.encryptedData = res.encryptedData;
          app.globalData.iv = res.iv;
          //触发成功回调
          that.triggerEvent("setAuthorization",res);
        } else {
          that.setData({
            showModel: true
          })
        }
      } catch (e) {
        wx.showModal({
          title: '系统提示',
          content: '网络错误',
          confirmText: '确定',
          confirmColor: '#35ca14',
          showCancel: false,
          success: function (res) {
            if (res.confirm) {
            }
          }
        })
      }
    },
  }
})
